﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Emmajn.ChildParentExtension.SilverlightClassLibrary
{
    public class Number
    {
        private int areaNumber;
        private int groupNumber;
        private int serialNumber;

        /// <param name="areaNumber">The first set of three digits</param>
        /// <param name="groupNumber">The second set of two digits</param>
        /// <param name="serialNumber">The final set of four digits</param>
        public Number(int areaNumber, int groupNumber, int serialNumber)
        {
            AreaNumber = areaNumber;
            GroupNumber = groupNumber;
            SerialNumber = serialNumber;
        }
        /// <summary>
        /// The first set of three digits
        /// </summary>
        public int AreaNumber
        {
            get
            {
                return areaNumber;
            }
            set
            {
                if (value < 0 || value > 999)
                    throw new ArgumentOutOfRangeException();
                else
                    areaNumber = value;
            }
        }

        /// <summary>
        /// The second set of two digits
        /// </summary>
        public int GroupNumber
        {
            get
            {
                return groupNumber;
            }
            set
            {
                if (value < 0 || value > 99)
                    throw new ArgumentOutOfRangeException();
                else
                    groupNumber = value;
            }
        }

        /// <summary>
        /// The final set of four digits
        /// </summary>
        public int SerialNumber
        {
            get
            {
                return serialNumber;
            }
            set
            {
                if (value < 0 || value > 9999)
                    throw new ArgumentOutOfRangeException();
                else
                    serialNumber = value;
            }
        }

        public override string ToString()
        {
            return string.Format("{0:000}-{1:00}-{2:0000}", areaNumber, groupNumber, serialNumber);
        }
    }
}
